home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * MIDI.h
- *
- * This file contains the c-language interface for the MIDI Manager.
- *
- * Author: John Worthington, Don Marsh, Mark Lentczner
- * Copyright © 1988-90, Apple Computer, Inc.
- * All Rights Reserved
- *
- * Version 2.0a1
- */
-
- #ifndef __MIDI__
- #define __MIDI__
-
- #include <Types.h>
-
-
- /*
- * Constants:
- */
-
- #define midiToolNum 4 /*tool number of MIDI Manager for SndDispVersion call*/
-
- #define midiMaxNameLen 31 /*maximum number of characters in port and client names*/
-
-
- /*Time formats*/
-
- #define midiFormatMSec 0 /*milliseconds*/
- #define midiFormatBeats 1 /*beats*/
- #define midiFormat24fpsBit 2 /*24 frames/sec.*/
- #define midiFormat25fpsBit 3 /*25 frames/sec.*/
- #define midiFormat30fpsDBit 4 /*30 frames/sec. drop-frame*/
- #define midiFormat30fpsBit 5 /*30 frames/sec.*/
- #define midiFormat24fpsQF 6 /*24 frames/sec. longInt format */
- #define midiFormat25fpsQF 7 /*25 frames/sec. longInt format */
- #define midiFormat30fpsDQF 8 /*30 frames/sec. drop-frame longInt format */
- #define midiFormat30fpsQF 9 /*30 frames/sec. longInt format */
-
- #define midiInternalSync 0 /*internally synced*/
- #define midiExternalSync 1 /*externally synced*/
-
- /*Port types*/
-
- #define midiPortTypeTime 0 /*time port*/
- #define midiPortTypeInput 1 /*input port*/
- #define midiPortTypeOutput 2 /*output port*/
- #define midiPortTypeTimeInv 3 /*invisible time port*/
- #define midiPortInvisible 0x8000 /*add this to other types to make invisible ports */
- #define midiPortTypeMask 0x0007 /*AND with this to convert new port types to old,
- ie. to strip the property bits */
-
- /*OffsetTimes*/
-
- #define midiGetEverything 0x7FFFFFFF /*get all packets, regardless of time stamps*/
- #define midiGetNothing 0x80000000 /*get no packets, regardless of time stamps*/
- #define midiGetCurrent 0x00000000 /*get current packets only*/
-
-
-
- /*
- * MIDI data and messages are passed in MIDIPacket records (see below).
- * The first byte of every MIDIPacket contains a set of flags
- *
- * bits 0-1 00 = new MIDIPacket, not continued
- * 01 = begining of continued MIDIPacket
- * 10 = end of continued MIDIPacket
- * 11 = continuation
- * bits 2-3 reserved
- *
- * bits 4-6 000 = packet contains MIDI data
- * 001 = packet contains MIDI Manager message
- *
- * bit 7 0 = MIDIPacket has valid stamp
- * 1 = stamp with current clock
- *
- */
-
- #define midiContMask 0x03
- #define midiNoCont 0x00
- #define midiStartCont 0x01
- #define midiMidCont 0x03
- #define midiEndCont 0x02
-
- #define midiTypeMask 0x70
- #define midiMsgType 0x00
- #define midiMgrType 0x10
-
- #define midiTimeStampMask 0x80
- #define midiTimeStampCurrent 0x80
- #define midiTimeStampValid 0x00
-
-
- /*
- * MIDI Manager MIDIPacket command words (the first word in the data field
- * for midiMgrType messages)
- */
-
- #define midiOverflowErr 0x0001
- #define midiSCCErr 0x0002
- #define midiPacketErr 0x0003
- #define midiMaxErr 0x00FF /*all command words less than this value*/
- /* are error indicators*/
-
- /* Valid results to be returned by readHooks */
-
- #define midiKeepPacket 0
- #define midiMorePacket 1
- #define midiNoMorePacket 2
- #define midiHoldPacket 3
-
-
- /*
- * Errors:
- */
-
- #define midiNoClientErr -250 /*no client with that ID found*/
- #define midiNoPortErr -251 /*no port with that ID found*/
- #define midiTooManyPortsErr -252 /*too many ports already installed in the system*/
- #define midiTooManyConsErr -253 /*too many connections made*/
- #define midiVConnectErr -254 /*pending virtual connection created*/
- #define midiVConnectMade -255 /*pending virtual connection resolved*/
- #define midiVConnectRmvd -256 /*pending virtual connection removed*/
- #define midiNoConErr -257 /*no connection exists between specified ports*/
- #define midiWriteErr -258 /*MIDIWritePacket couldn't write to all connected ports*/
- #define midiNameLenErr -259 /*name supplied is longer than 31 characters*/
- #define midiDupIDErr -260 /*duplicate client ID*/
- #define midiInvalidCmdErr -261 /*command not supported for port type*/
-
-
- /*
- * Driver calls:
- */
-
- #define midiOpenDriver 1
- #define midiCloseDriver 2
-
-
- /*
- * MIDI data and other messages are read and written via packets:
- */
-
- typedef struct MIDIPacket {
- unsigned char flags;
- unsigned char len;
- long tStamp;
- unsigned char data[249];
- } MIDIPacket;
-
- typedef MIDIPacket *MIDIPacketPtr;
-
-
-
- /*
- * Clocks:
- */
-
- typedef struct MIDIClkInfo {
- short sync; /*synchronization external/internal*/
- long curTime; /*current value of port's clock*/
- short format; /*time code format*/
- } MIDIClkInfo;
-
-
- /*
- * port information
- */
-
- typedef struct MIDIIDRec {
- OSType clientID;
- OSType portID;
- } MIDIIDRec;
-
-
- typedef struct MIDIPortInfo {
- short type; /*type of port*/
- MIDIIDRec timeBase; /*MIDIIDRec for time base*/
- short numConnects; /*number of connections*/
- MIDIIDRec cList[]; /*ARRAY [1..numConnects] of MIDIIDRec */
- } MIDIPortInfo;
-
- typedef MIDIPortInfo *MIDIPortInfoPtr, **MIDIPortInfoHdl;
-
-
- typedef struct MIDIPortParams {
- OSType portID; /*ID of port, unique within client*/
- short portType; /*Type of port - input, output, time, etc.*/
- short timeBase; /*refnum of time base, 0 if none*/
- long offsetTime; /*offset for current time stamps*/
- Ptr readHook; /*routine to call when input data is valid*/
- long refCon; /*refcon for port (for client use)*/
- MIDIClkInfo initClock; /*initial settings for a time base*/
- Str255 name; /*name of the port, This is a real live string, not a ptr.*/
- } MIDIPortParams;
-
- typedef MIDIPortParams *MIDIPortParamsPtr;
-
-
-
- /*
- * ID List
- */
-
- typedef struct MIDIIDList {
- short numIDs;
- OSType list[];
- } MIDIIDList;
-
- typedef MIDIIDList *MIDIIDListPtr, **MIDIIDListHdl;
-
- /*
- * MDVR Control structs
- *
- */
-
- typedef struct MDVRInCtlRec {
- short timeCodeClock; /* refnum of time base for time code */
- short timeCodeFormat; /* format of time code output */
- ProcPtr readProc; /* proc to call with intput characters */
- ProcPtr commProc; /* proc to call for handshaking */
- long refCon /* refCon passed to readProc, commProc */
- } MDVRInCtlRec;
-
- typedef MDVRInCtlRec *MDVRInCtlPtr;
-
-
- typedef struct MDVROutCtlRec {
- short timeCodeClock; /* time base driven by time code */
- short timeCodeFormat; /* format of time code to listen to */
- ProcPtr timeCodeProc; /* proc called on time code fmt change */
- ProcPtr commProc; /* proc called for handshaking */
- long refCon; /* refCon passed to timeCodeProc */
- Boolean timeCodeFilter; /* filter time code if true */
- long midiMsgTicks; /* value of Ticks when MIDI msg rcvd */
- long timeCodeTicks; /* value of Ticks when time code rcvd */
- } MDVROutCtlRec;
-
- typedef MDVROutCtlRec *MDVROutCtlPtr;
-
- typedef void *MDVRPtr;
-
- #define mdvrAbortNotesOff 0; /* abort previous mdvrNotesOff request */
- #define mdvrChanNotesOff 1; /* generate channel note off messages */
- #define mdvrAllNotesOff 2; /* generate all note off messages */
-
- #define mdvrStopOut 0; /* stop calling MDVROut temporarily */
- #define mdvrStartOut 1; /* resume calling MDVROut */
-
-
- /*
- * Prototype Declarations for readHook and timeProc
- *
- * extern pascal short myReadHook(MIDIPacketPtr myPacket, long myRefCon);
- * extern pascal void myTimeProc(long curTime, long myRefCon);
- * extern pascal void connectionProc(short refnum, long refcon, short portType
- * OSType clientID, OSType portID, BOOLEAN connect, short direction);
- *
- *
- */
-
- /*
- * Protype Declarations for driver routines
- *
- *
- * extern pascal long CommProc(short refnum, short request, long refCon);
- * extern pascal void TimeCodeProc(short refnum, short newFormat, long refCon);
- * extern pascal void ReadProc (char *midiChars, short length, long refCon);
- *
- */
-
-
-
- /* MIDI Manager Routines */
-
- pascal long SndDispVersion(short toolnum) extern;
-
- pascal OSErr MIDISignIn(OSType clientID, long refCon, Handle icon, Str255 name)
- = {0x203C,4,midiToolNum,0xA800};
- pascal void MIDISignOut(OSType clientID)
- = {0x203C,8,midiToolNum,0xA800};
- pascal MIDIIDListHdl MIDIGetClients()
- = {0x203C,12,midiToolNum,0xA800};
- pascal void MIDIGetClientName(OSType clientID, Str255 name)
- = {0x203C,16,midiToolNum,0xA800};
- pascal void MIDISetClientName(OSType clientID, Str255 name)
- = {0x203C,20,midiToolNum,0xA800};
- pascal MIDIIDListHdl MIDIGetPorts(OSType clientID)
- = {0x203C,24,midiToolNum,0xA800};
- pascal OSErr MIDIAddPort(OSType clientID, short BufSize, short *refnum, MIDIPortParamsPtr init)
- = {0x203C,28,midiToolNum,0xA800};
- pascal MIDIPortInfoHdl MIDIGetPortInfo(OSType clientID, OSType portID)
- = {0x203C,32,midiToolNum,0xA800};
- pascal OSErr MIDIConnectData(OSType srcClID, OSType srcPortID, OSType dstClID, OSType dstPortID)
- = {0x203C,36,midiToolNum,0xA800};
- pascal OSErr MIDIUnConnectData(OSType srcClID, OSType srcPortID, OSType dstClID, OSType dstPortID)
- = {0x203C,40,midiToolNum,0xA800};
- pascal OSErr MIDIConnectTime(OSType srcClID, OSType srcPortID, OSType dstClID, OSType dstPortID)
- = {0x203C,44,midiToolNum,0xA800};
- pascal OSErr MIDIUnConnectTime(OSType srcClID, OSType srcPortID, OSType dstClID, OSType dstPortID)
- = {0x203C,48,midiToolNum,0xA800};
- pascal void MIDIFlush(short refnum)
- = {0x203C,52,midiToolNum,0xA800};
- pascal ProcPtr MIDIGetReadHook(short refnum)
- = {0x203C,56,midiToolNum,0xA800};
- pascal void MIDISetReadHook(short refnum, ProcPtr hook)
- = {0x203C,60,midiToolNum,0xA800};
- pascal void MIDIGetPortName(OSType clientID, OSType portID, Str255 name)
- = {0x203C,64,midiToolNum,0xA800};
- pascal void MIDISetPortName(OSType clientID, OSType portID, Str255 name)
- = {0x203C,68,midiToolNum,0xA800};
- pascal void MIDIWakeUp(short refnum, long time, long period, ProcPtr timeProc)
- = {0x203C,72,midiToolNum,0xA800};
- pascal void MIDIRemovePort(short refnum)
- = {0x203C,76,midiToolNum,0xA800};
- pascal short MIDIGetSync(short refnum)
- = {0x203C,80,midiToolNum,0xA800};
- pascal void MIDISetSync(short refnum, short sync)
- = {0x203C,84,midiToolNum,0xA800};
- pascal long MIDIGetCurTime(short refnum)
- = {0x203C,88,midiToolNum,0xA800};
- pascal void MIDISetCurTime(short refnum, long time)
- = {0x203C,92,midiToolNum,0xA800};
- pascal void MIDIStartTime(short refnum)
- = {0x203C,96,midiToolNum,0xA800};
- pascal void MIDIStopTime(short refnum)
- = {0x203C,100,midiToolNum,0xA800};
- pascal void MIDIPoll(short refnum, long offsetTime)
- = {0x203C,104,midiToolNum,0xA800};
- pascal OSErr MIDIWritePacket(short refnum, MIDIPacketPtr packet)
- = {0x203C,108,midiToolNum,0xA800};
- pascal Boolean MIDIWorldChanged(OSType clientID)
- = {0x203C,112,midiToolNum,0xA800};
- pascal long MIDIGetOffsetTime(short refnum)
- = {0x203C,116,midiToolNum,0xA800};
- pascal void MIDISetOffsetTime(short refnum, long offsetTime)
- = {0x203C,120,midiToolNum,0xA800};
- pascal long MIDIConvertTime(short srcformat, short dstformat, long time)
- = {0x203C,124,midiToolNum,0xA800};
- pascal long MIDIGetRefCon(short refnum)
- = {0x203C,128,midiToolNum,0xA800};
- pascal void MIDISetRefCon(short refnum, long refCon)
- = {0x203C,132,midiToolNum,0xA800};
- pascal long MIDIGetClRefCon(OSType clientID)
- = {0x203C,136,midiToolNum,0xA800};
- pascal void MIDISetClRefCon(OSType clientID, long refCon)
- = {0x203C,140,midiToolNum,0xA800};
- pascal short MIDIGetTCFormat(short refnum)
- = {0x203C,144,midiToolNum,0xA800};
- pascal void MIDISetTCFormat(short refnum, short format)
- = {0x203C,148,midiToolNum,0xA800};
- pascal void MIDISetRunRate(short refnum, short rate, long time)
- = {0x203C,152,midiToolNum,0xA800};
- pascal Handle MIDIGetClientIcon(OSType clientID)
- = {0x203C,156,midiToolNum,0xA800};
- pascal ProcPtr MIDICallAddress(short callNum)
- = {0x203C,164,midiToolNum,0xA800};
- pascal void MIDISetConnectionProc(short refNum, ProcPtr connectionProc, long refCon)
- = {0x203C,168,midiToolNum,0xA800};
- pascal void MIDIGetConnectionProc(short refnum, ProcPtr *connectionProc, long *refCon)
- = {0x203C, 172,midiToolNum,0xA800};
- pascal void MIDIDiscardPacket(short refnum, MIDIPacketPtr packet)
- = {0x203C, 176,midiToolNum,0xA800};
- pascal OSErr MDVRSignIn(OSType clientID, long refCon, Handle icon, Str255 name)
- = {0x203C,180,midiToolNum,0xA800};
- pascal void MDVRSignOut(OSType clientID)
- = {0x203C,184,midiToolNum,0xA800};
- pascal MDVRPtr MDVROpen(short portType, short refnum)
- = {0x203C,188,midiToolNum,0xA800};
- pascal void MDVRClose(MDVRPtr driverPtr)
- = {0x203C,192,midiToolNum,0xA800};
- pascal void MDVRControlIn(MDVRPtr portPtr, MDVRInCtlPtr inputCtl)
- = {0x203C,196,midiToolNum,0xA800};
- pascal void MDVRControlOut(MDVRPtr portPtr, MDVROutCtlPtr outputCtl)
- = {0x203C,200,midiToolNum,0xA800};
- pascal void MDVRIn(MDVRPtr portPtr)
- = {0x203C,204,midiToolNum,0xA800};
- pascal void MDVROut(MDVRPtr portPtr, char *dataPtr, short length)
- = {0x203C,208,midiToolNum,0xA800};
- pascal void MDVRNotesOff(MDVRPtr portPtr, short mode)
- = {0x203C,212,midiToolNum,0xA800};
-
-
- #endif
-
-
-